package org.app.demo.spring.controller;

 

import javax.servlet.http.HttpServletRequest;

import org.app.demo.spring.service.HelloWorldService;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;

 


@Controller
@RequestMapping("/my")
public class HelloWorldController{
 
       @Autowired
       private HelloWorldService helloWorldService;//注入服务
       
       
       @RequestMapping("/helloworld.action")//设置映射
       public String getNewName(@RequestParam("userName") String userName, HttpServletRequest request){
              String newUserName = helloWorldService.getNewName(userName);
              request.setAttribute("newUserName", newUserName);
              return "helloworld";

       }

}

